var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0}), (o.AssetsType = void 0);
var n,
    a = e("Loader"),
    i = e("AudioManager"),
    r = cc._decorator,
    s = r.ccclass;
r.property,
    (function (e) {
        (e[(e.Prefabs = 1)] = "Prefabs"),
            (e[(e.Sprite = 2)] = "Sprite"),
            (e[(e.Atlas = 3)] = "Atlas"),
            (e[(e.Audio = 4)] = "Audio"),
            (e[(e.Bundle = 5)] = "Bundle");
    })((n = o.AssetsType || (o.AssetsType = {})));
var l = (function () {
    function e() {
        (this.Prefabs = {}),
            (this.Sprite = {}),
            (this.Atlas = {}),
            (this.Audio = {}),
            (this.FightProfabs = {}),
            (this.FightAddName = []);
    }
    var t;
    return (
        (t = e),
        (e.getInstance = function () {
            return this.instance || (this.instance = new t()), this.instance;
        }),
        (e.prototype.loadFolder = function (e, t) {
            return __awaiter(this, void 0, void 0, function () {
                var o;
                return __generator(this, function () {
                    switch (((o = null), t)) {
                        case n.Prefabs:
                            o = this.loadPrefabs(e);
                            break;
                        case n.Sprite:
                            o = this.loadSprite(e);
                            break;
                        case n.Atlas:
                            o = this.loadAtlas(e);
                            break;
                        case n.Audio:
                            o = this.loadAudio(e);
                            break;
                        case n.Bundle:
                            o = this.loadBundlePrefabs(e);
                    }
                    return [2, o];
                });
            });
        }),
        (e.prototype.loadPrefabs = function (e) {
            var t = this;
            return new Promise(function (o, n) {
                cc.resources.loadDir(e, cc.Prefab, null, function (e, a) {
                    if (e) n(e);
                    else {
                        for (var i = 0; i < a.length; i++) a[i] && (t.Prefabs[a[i].name] = a[i]);
                        o();
                    }
                });
            });
        }),
        (e.prototype.loadBundlePrefabs = function (e) {
            var t = this;
            return new Promise(function (o) {
                cc.assetManager.getBundle(e)._config.paths.forEach(function (o, n) {
                    a.default.loadBundleRes(
                        e,
                        n,
                        function (e) {
                            t.Prefabs[n] = e;
                        },
                        cc.Prefab
                    );
                }),
                    o();
            });
        }),
        (e.prototype.loadSprite = function (e) {
            var t = this;
            return new Promise(function (o, n) {
                cc.loader.loadResDir(e, cc.Texture2D, function (e, a, i) {
                    if (e) n(e);
                    else {
                        for (var r = 0; r < a.length; r++)
                            if (i[r] && a[r]) {
                                var s = cc.path.basename(i[r]);
                                t.Sprite[s] = a[r];
                            }
                        o();
                    }
                });
            });
        }),
        (e.prototype.loadAtlas = function () {
            var e = this;
            return new Promise(function (t) {
                cc.assetManager.getBundle("Atlas")._config.paths.forEach(function (t, o) {
                    a.default.loadBundleRes(
                        "Atlas",
                        o,
                        function (t) {
                            var n = "" + o;
                            e.Atlas[n + ".plist"] = t;
                        },
                        cc.SpriteAtlas
                    );
                }),
                    t();
            });
        }),
        (e.prototype.loadAudio = function (e) {
            var t = this;
            return new Promise(function (o, n) {
                cc.resources.loadDir(e, cc.AudioClip, null, function (e, a) {
                    if (e) n(e);
                    else {
                        for (var r = 0; r < a.length; r++)
                            a[r] && ((t.Audio[a[r].name] = a[r]), i.default.getInstance().addSound(a[r].name, a[r]));
                        o();
                    }
                });
            });
        }),
        (e.prototype.getPrefabNode = function (e) {
            return this.Prefabs[e];
        }),
        (e.prototype.loadFightPrefabs = function (e) {
            var t = this;
            return new Promise(function (o) {
                cc.assetManager.getBundle(e)._config.paths.forEach(function (o, n) {
                    a.default.loadBundleRes(
                        e,
                        n,
                        function (e) {
                            t.FightProfabs[n] = e;
                        },
                        cc.Prefab
                    );
                }),
                    o();
            });
        }),
        (e.prototype.loadFightRolePrefabs = function (e) {
            var t = this;
            return (
                (this.FightAddName = e),
                new Promise(function (o, n) {
                    for (var a = 0; a < e.length; a++) {
                        var i = e[a];
                        cc.resources.load(i, cc.Prefab, null, function (e, o) {
                            e ? n(e) : (t.FightProfabs[o.name] = o);
                        });
                    }
                    o();
                })
            );
        }),
        (e.prototype.loadFightAudio = function (e) {
            var t = this;
            return new Promise(function (o, n) {
                cc.resources.loadDir(e, cc.AudioClip, null, function (e, a) {
                    if (e) n(e);
                    else {
                        for (var r = 0; r < a.length; r++)
                            a[r] &&
                                ((t.Audio[a[r].name] = a[r]), i.default.getInstance().addFightSound(a[r].name, a[r]));
                        o();
                    }
                });
            });
        }),
        (e.prototype.getPlayerLevelExp = function (e) {
            return this.Atlas["level_atlas.plist"].getSpriteFrame("level_" + e);
        }),
        (e.prototype.getHeroHeadFrame = function (e) {
            return this.Atlas["hero_head.plist"].getSpriteFrame(e);
        }),
        (e.prototype.getGameHoreHeadFrame = function (e) {
            return this.Atlas["game_hero_head.plist"].getSpriteFrame(e);
        }),
        (e.prototype.getGradeTypeFrame = function (e) {
            return this.Atlas["grade_type.plist"].getSpriteFrame(e);
        }),
        (e.prototype.getDowerImagerFrame = function (e) {
            return this.Atlas["dower_image.plist"].getSpriteFrame(e);
        }),
        (e.prototype.getHeroCardFrame = function (e) {
            return this.Atlas["hero_card.plist"].getSpriteFrame(e);
        }),
        (e.prototype.getHeroSkilIcon = function (e) {
            return this.Atlas["hero_skill_icon.plist"].getSpriteFrame(e);
        }),
        (e.prototype.getPlayerSkillFrame = function (e) {
            return this.Atlas["player_skill.plist"].getSpriteFrame(e);
        }),
        (e.prototype.getPlayerHeadFrame = function (e) {
            return this.Atlas["head_image.plist"].getSpriteFrame(e);
        }),
        (e.prototype.getEquipIconFrame = function (e) {
            return this.Atlas["equip_icon.plist"].getSpriteFrame(e);
        }),
        (e.prototype.getFightPrefab = function (e) {
            return this.FightProfabs[e];
        }),
        (t = __decorate([s], e))
    );
})();
o.default = l;
